<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<title>crossdomain | Flash URLLoader</title>
	<meta http-equiv="X-UA-Compatible" content="IE=Edge">
	<style>
	body, button{
		font-family: Verdana, Arial;
		color: #333;
	}
	h1{
		text-align:center;
		font-size:24px;
	}
	</style>
</head>
<body>
	<h1>crossdomain using Flash URLLoader</h1>
	<button id='get_resource'>Click to get resource</button>
	<p id='resource_holder'></p>
	<script src='http://ajax.googleapis.com/ajax/libs/yui/2.8.1/build/yuiloader/yuiloader-min.js'></script>
	<script>
	var YUIReady = function(){
			var YC =  YAHOO.util.Connect,
				  Event =YAHOO.util.Event,
				  Dom = YAHOO.util.Dom,
				  button = Dom.get('get_resource'),
				  holder = Dom.get('resource_holder'),
				  url = 'http://www.b.com/crossdomain/flash-urlloader/resource.php',
				  callback = {
					  success : function(e, d){
							holder.innerHTML =new Date() + ": " + e.responseText;
					  },
					  failure : function(){
						  alert('failure');
					  },
					  xdr: true
				  };

			 YC.xdrReadyEvent.subscribe(function(){
				 Event.addListener(button, "click", function(){
					 holder.innerHTML = '';
					 YC.asyncRequest('GET', url, callback);
				 });
			 });
			
			YC.transport('connection.swf');
	};

	new YAHOO.util.YUILoader({
		require: ["connection", 'dom'],
		loadOptional: true,
		onSuccess: function() {
			YUIReady();
		},
		timeout: 10000,
		combine: true
	}).insert();
	</script>
</body>
</html>
